package org.uk.splitsbrowser.client.presenter;

import java.util.List;

import com.google.gwt.place.shared.Place;
import com.google.gwt.activity.*;
import com.google.gwt.core.client.GWT;

import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.Range;
import com.google.gwt.view.client.RangeChangeEvent;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SelectionModel;
import org.uk.splitsbrowser.shared.OEvent;
import org.uk.splitsbrowser.client.view.EventBrowser;


public class BrowseEventsActivity {
	
	// Definition of the interface used by the browse events view 
	public class IViewInterface {
		
	}
	
	private static EventBrowser browser = new EventBrowser();
	
	

		  private static class MyDataProvider extends AsyncDataProvider<String> {
		    /**
		     * {@link #onRangeChanged(HasData)} is called when the table requests a new
		     * range of data. You can push data back to the displays using
		     * {@link #updateRowData(int, List)}.
		     */
		    @Override
		    protected void onRangeChanged(HasData<String> display) {
		      // Get the new range.
		      final Range range = display.getVisibleRange();
		      
		      // Make RPC call to get requested data range
		      OEventServiceAsync service = GWT.create(OEventService.class);
		      		      
		      /* Callback object */ 
	          AsyncCallback<List<OEvent>> callback = new AsyncCallback<List<OEvent>>() {
	            public void onFailure(Throwable caught) {
	              // TODO: Do something with errors.
	            }

	            public void onSuccess(List<OEvent> result) {
	            //     cellList.setRowData(range.getStart(), result);
	            }
	          };
	          
		      service.queryEvent("", range.getStart(), range.getLength(), callback);
		    }
		  }

	}

